/*
 * Created on 17-abr-06
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.jma.lib.utils.xml;
/**
 * @author jesus
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class XsiClassMapper{

	static String nameSpace="xsd:";
		
	public static Class getJavaClass(String xsiClass) {
		if (xsiClass.equals("string")) return String.class;
		if (xsiClass.equals("base64Binary")) return Byte[].class;
		if (xsiClass.equals("boolean")) return boolean.class;
		if (xsiClass.equals("byte")) return byte.class;
		if (xsiClass.equals("dateTime")) return java.util.Calendar.class;
		if (xsiClass.equals("decimal")) return java.math.BigDecimal.class;
		if (xsiClass.equals("float")) return float.class;
		if (xsiClass.equals("hexBinary")) return byte[].class;
		if (xsiClass.equals("int")) return int.class;
		if (xsiClass.equals("integer")) return java.math.BigInteger.class;
		if (xsiClass.equals("long")) return long.class;
		if (xsiClass.equals("short")) return short.class;
		return Object.class;
	}
	
	public static String getXsiClass(Class javaClass){
		if (javaClass==String.class) return nameSpace+"string";
		if (javaClass==Byte[].class) return nameSpace+"base64Binary";
		if (javaClass==boolean.class) return nameSpace+"boolean";
		if (javaClass==Boolean.class) return nameSpace+"boolean";
		if (javaClass==byte.class) return nameSpace+"byte";
		if (javaClass==Byte.class) return nameSpace+"byte";
		if (javaClass==java.util.Calendar.class) return nameSpace+"dateTime";
		if (javaClass==java.sql.Date.class) return nameSpace+"dateTime";
		if (javaClass==java.sql.Timestamp.class) return nameSpace+"dateTime";
		if (javaClass==java.math.BigDecimal.class) return nameSpace+"decimal";
		if (javaClass==float.class) return nameSpace+"float";
		if (javaClass==Float.class) return nameSpace+"float";
		if (javaClass==byte[].class) return nameSpace+"hexBinary";
		if (javaClass==int.class) return nameSpace+"int";
		if (javaClass==Integer.class) return nameSpace+"int";
		if (javaClass==java.math.BigInteger.class) return nameSpace+"integer";
		if (javaClass==long.class) return nameSpace+"long";
		if (javaClass==Long.class) return nameSpace+"long";
		if (javaClass==short.class) return nameSpace+"short";
		if (javaClass==Short.class) return nameSpace+"short";
		return nameSpace+"anyType";	
	}

	/**
	 * @return
	 */
	public String getNameSpace() {
		return nameSpace.substring(0,nameSpace.length()-1);
	}

	/**
	 * @param string
	 */
	public void setNameSpace(String nameSpace) {
		nameSpace = nameSpace+":";
	}

}
